package edu.cmu.cs.stage3.alice.authoringtool.editors.compositeeditor;

import edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool;

public class ComponentElementPanel extends edu.cmu.cs.stage3.alice.authoringtool.util.DnDGroupingPanel{

	protected edu.cmu.cs.stage3.alice.core.Element m_element;

	public ComponentElementPanel(){
		this.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
		this.remove(grip);
	}

	public void set(edu.cmu.cs.stage3.alice.core.Element element) {
		m_element = element;
		try{
			this.add(edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getGUI(m_element));
		}
		catch (Exception e){
			AuthoringTool.getInstance().showErrorDialog( "An error occurred while creating the graphics component for this object.", e );
		}
	}

	protected java.awt.Color getCustomBackgroundColor(){
		if (this.getComponentCount() > 0){
			return this.getComponent(0).getBackground();
		}
		return java.awt.Color.white;
	}

	public boolean isDisabled(){
		return false;
	}

	public void clean() {
		removeAll();
	}

	public edu.cmu.cs.stage3.alice.core.Element getElement(){
		return m_element;
	}



}